package cn.wenhe9.hefengweather.ui.weather

import android.util.Log
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import cn.wenhe9.hefengweather.logic.Repository

/**
 *@author DuJinliang
 *2021/10/1
 */
class WeatherViewModel : ViewModel() {
    private val locationIdLiveData = MutableLiveData<String>()

    var placeName = ""

    var locationId = ""

    val weatherLiveData = Transformations.switchMap(locationIdLiveData){ locationId ->
        Repository.refreshWeather(locationId)
    }

    fun refreshWeather(locationId : String){
        locationIdLiveData.value = locationId
    }
}